package main

/*
#include <stdlib.h>
typedef void (*CallbackFunc_T)(char *, int);
CallbackFunc_T mycall = NULL;
*/
import "C"
import (
	"fmt"
	"unsafe"
)

// // https://www.cnblogs.com/jiftle/p/17401593.html

// var mycall C.CallbackFunc_T

//export setCallback
func setCallback(cb C.CallbackFunc_T) {
	C.mycall = cb
	fmt.Println(unsafe.Pointer(cb))
}

//export triggerCallback
func triggerCallback() {
	// 如果存在回调函数，使用提供的参数调用回调函数
	str := C.CString("Hello from Golang")
	// cb2 := unsafe.Pointer(mycall)

	// C.mycall(str, C.int(42))
	defer C.free(unsafe.Pointer(str))
}

func main() {}
